package com.shopping.service;

import com.shopping.entity.OrderInfo;
import com.shopping.entity.User;
import com.shopping.vo.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MiaoshaService {

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private OrderService orderService;


    @Transactional
    public OrderInfo miaosha(User user, GoodsVO goodsVOByGoodsId) {
        //减库存、下订单、写入秒杀订单
        goodsService.reductStock(goodsVOByGoodsId);

        return orderService.createOrder(user,goodsVOByGoodsId);
    }
}
